<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./template.xhtml">
            <ui:define name="mainMenu">
                <ui:include src="mainMenu.xhtml"/>
            </ui:define>
            <ui:define name="navigation">
                <ui:include src="menu.xhtml">
                    <ui:param name="select" value="#{4}"/>
                </ui:include>
            </ui:define>

            <ui:define name="content">
                <h1>
                    <h:outputText value="#{bundle.STitle}" />
                </h1>
                <h:form>
                    <h:panelGrid styleClass="panelGrid" columns="2" columnClasses="rightAlign, leftAlign">

                        <h:outputText value="#{bundle.SFilmName}"/>
                        <h:inputText id="filmName"
                                     label="#{bundle.SFilmName}"
                                     value="#{searchBean.filmName}"/>

                        <h:outputText value="#{bundle.SUser}"/>
                        <h:selectOneListbox value="#{searchBean.user}" size="1" >
                            <f:selectItem itemLabel="-"/>
                            <c:forEach items="#{searchBean.users}" var="u">
                                <f:selectItem itemValue="#{u}" itemLabel="#{u}"/>
                            </c:forEach>
                        </h:selectOneListbox>

                        <h:outputText value="#{bundle.SGenre}"/>
                        <h:selectManyListbox  label="#{bundle.Genre}" value="#{searchBean.genre}" size="10">
                            <c:if test="#{localeBean.language == 'pl'}">
                                <c:forEach items="#{searchBean.genres}" var="g">
                                    <f:selectItem itemValue="#{g.namePl}" itemLabel="#{g.namePl}"/>
                                </c:forEach>
                            </c:if>
                            <c:if test="#{localeBean.language == 'en'}">
                                <c:forEach items="#{searchBean.genres}" var="g">
                                    <f:selectItem itemValue="#{g.nameEn}" itemLabel="#{g.nameEn}"/>
                                </c:forEach>
                            </c:if>

                        </h:selectManyListbox>


                        <h:outputText value="#{bundle.SQuality}"/>
                        <h:selectOneListbox value="#{searchBean.quality}" size="1" >
                            <f:selectItem itemLabel="-"/>
                            <c:forEach items="#{searchBean.qualities}" var="q">
                                <f:selectItem itemValue="#{q.name}" itemLabel="#{q.name}"/>
                            </c:forEach>
                        </h:selectOneListbox>



                        <h:outputText value="#{bundle.SSize}"/>
                        <h:panelGroup>
                            <h:outputText value="#{bundle.SFrom}"/>
                            <h:inputText id="sizeFrom" maxlength="6" size="6" required="true"
                                         value="#{searchBean.sizeFrom}"
                                         label="#{bundle.Size}"/>
                            <h:outputText value=" "/>
                            <h:outputText value="#{bundle.STo}"/>
                            <h:inputText id="sizeTo" maxlength="6" size="6" required="true"
                                         label="#{bundle.Size}"
                                         value="#{searchBean.sizeTo}"/>
                        </h:panelGroup>

                        <h:outputText value="#{bundle.SYear}"/>
                        <h:panelGroup>
                            <h:outputText value="#{bundle.SFrom}"/>
                            <h:selectOneListbox value="#{searchBean.yearFrom}" size="1" >
                                <f:selectItem itemValue="0" itemLabel="-"/>
                                <c:forEach items="#{searchBean.years}" var="q">
                                    <f:selectItem itemValue="#{q}" itemLabel="#{q}"/>
                                </c:forEach>
                            </h:selectOneListbox>
                            <h:outputText value=" "/>
                            <h:outputText value="#{bundle.STo}"/>
                            <h:selectOneListbox value="#{searchBean.yearTo}" size="1" >
                                <f:selectItem itemValue="0" itemLabel="-"/>
                                <c:forEach items="#{searchBean.years}" var="q">
                                    <f:selectItem itemValue="#{q}" itemLabel="#{q}"/>
                                </c:forEach>
                            </h:selectOneListbox>
                        </h:panelGroup>

                        <h:outputText value="#{bundle.SRank}"/>
                        <h:panelGroup>
                            <h:outputText value="#{bundle.SFrom}"/>
                            <h:selectOneListbox value="#{searchBean.rankFrom}" size="1" >
                                <f:selectItem itemValue="0" itemLabel="-"/>
                                <c:forEach items="#{searchBean.ranks}" var="q">
                                    <f:selectItem itemValue="#{q}" itemLabel="#{q}"/>
                                </c:forEach>
                            </h:selectOneListbox>
                            <h:outputText value=" "/>
                            <h:outputText value="#{bundle.STo}"/>
                            <h:selectOneListbox value="#{searchBean.rankTo}" size="1" >
                                <f:selectItem itemValue="0" itemLabel="-"/>
                                <c:forEach items="#{searchBean.ranks}" var="q">
                                    <f:selectItem itemValue="#{q}" itemLabel="#{q}"/>
                                </c:forEach>
                            </h:selectOneListbox>
                        </h:panelGroup>


                        <h:panelGroup> </h:panelGroup>
                        <h:commandButton value="#{bundle.SSearch}" action="#{searchBean.search}"/>
                    </h:panelGrid>
                    <h:messages styleClass="errorMsg" > </h:messages>

                </h:form>
                <h3>
                    <h:outputText style="margin-left: 50px;" value="#{bundle.SResult}" rendered="#{searchBean.f!=null}" />
                </h3>
                <h:dataTable styleClass="panelGrid" value="#{searchBean.f}" var="mf">
                    <h:column>


                        <h:link value="#{mf.titleOrg}" outcome="filmpage" >
                            <f:param name="id" value="#{mf.idfilms}" />
                        </h:link>

                    </h:column>

                    <h:column>
                        #{mf.titleEn}
                    </h:column>

                    <h:column>
                        #{mf.titlePl}
                    </h:column>
                     <h:column>
                        
                        #{mf.users.username}
                    </h:column>

                    <h:column>
                        #{mf.quality.name}
                    </h:column>
                    <h:column>
                        #{mf.fileSize}
                    </h:column>
                    <h:column>
                        #{mf.year}
                    </h:column>

                </h:dataTable>
            </ui:define>

        </ui:composition>

    </body>
</html>
